uniform extern texture ScreenTexture;   
float blurRadius = 0.005f;
float timeraslow=1.0;

sampler screen = sampler_state
{
    Texture = <ScreenTexture>;
};
 
float4 Gray(float2 inCoord: TEXCOORD0) : COLOR
{
    float4 color = tex2D(screen, inCoord);
 
    color.rgb = (color.r+color.g+color.b)/3.0f;

    return color;
}

float4 Blur(float2 inCoord: TEXCOORD0) : COLOR
{
	float4 Color;
	Color = tex2D(screen, inCoord.xy);
	Color += tex2D(screen, inCoord.xy + blurRadius);
	Color += tex2D(screen, inCoord.xy - blurRadius);
	Color = Color / 3;

    return Color;
}

float4 Negative(float2 inCoord: TEXCOORD0) : COLOR
{
    return 1-tex2D(screen, inCoord.xy);
}

float4 Water(float2 inCoord: TEXCOORD0) : COLOR
{ 
	inCoord.y = inCoord.y  + (sin(inCoord.y*timeraslow)*0.0025);
	inCoord.x = inCoord.x + (cos(inCoord.x*timeraslow)*0.0025);
	return tex2D( screen , inCoord.xy);
	
}

float4 Sketch(float2 inCoord: TEXCOORD0) : COLOR
{ 
	float4 Color = tex2D( screen , inCoord);
	Color.rgb = (Color.r+Color.g+Color.b)/3.0f; 
	if (Color.r<0.2 || Color.r>0.9) Color.r = 0; else Color.r = 1.0f; 
	if (Color.g<0.2 || Color.g>0.9) Color.g = 0; else Color.g = 1.0f; 
	if (Color.b<0.2 || Color.b>0.9) Color.b = 0; else Color.b = 1.0f;

	return Color;
}

float4 Quake( float2 Tex : TEXCOORD0 ) : COLOR0
{
    float4 Color;
    //Tex.y = Tex.y + (sin(timeraslow)*0.1);
    Tex.x = Tex.x + (cos(timeraslow)*0.01);
   	Color = tex2D( screen, Tex.xy);
    return Color;
}


technique test
{
    pass Gray
    {
        PixelShader = compile ps_2_0 Gray();
    }
	pass Negative
    {
        PixelShader = compile ps_2_0 Negative();
    }
	pass Blur
    {
        PixelShader = compile ps_2_0 Blur();
    }
	pass Water
    {
        PixelShader = compile ps_2_0 Water();
    }
	pass Sketch
    {
        PixelShader = compile ps_2_0 Sketch();
    }
	pass Quake
    {
		//VertexShader = null;
        PixelShader = compile ps_2_0 Quake();
	}
}